"use strict";
cc._RF.push(module, '04105hiMEhM04bn/nXGON/8', 'Subtitle');
// eazax-ccc/components/Subtitle.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Subtitle = /** @class */ (function (_super) {
    __extends(Subtitle, _super);
    function Subtitle() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.label = null;
        _this.queen = [];
        _this.curIndex = 0;
        _this.interval = 1.5;
        return _this;
    }
    Subtitle_1 = Subtitle;
    Subtitle.prototype.onLoad = function () {
        Subtitle_1.instance = this;
    };
    /**
     * 打印字幕
     * @param texts 文本
     * @param interval 间隔
     */
    Subtitle.print = function (texts, interval) {
        if (interval === void 0) { interval = 1.5; }
        this.instance.print(texts, interval);
    };
    /**
     * 清除字幕
     */
    Subtitle.clear = function () {
        this.instance.clear();
    };
    /**
     * 打印字幕
     * @param texts 文本
     * @param interval 间隔
     */
    Subtitle.prototype.print = function (texts, interval) {
        if (interval === void 0) { interval = 1.5; }
        if (texts.length === 0)
            return;
        this.unscheduleAllCallbacks();
        this.queen = texts;
        this.interval = interval;
        this.curIndex = -1;
        this.next();
        // this.schedule(() => this.next(), this.interval, cc.macro.REPEAT_FOREVER, this.interval);
    };
    /**
     * 下一条字幕
     */
    Subtitle.prototype.next = function () {
        var _this = this;
        this.curIndex++;
        if (this.curIndex >= this.queen.length) {
            this.unscheduleAllCallbacks();
            return;
        }
        this.label.string = this.queen[this.curIndex];
        this.scheduleOnce(function () { return _this.next(); }, this.interval);
    };
    /**
     * 清除字幕
     */
    Subtitle.prototype.clear = function () {
        this.unscheduleAllCallbacks();
        this.queen = [];
        this.curIndex = 0;
        this.label.string = '';
    };
    var Subtitle_1;
    Subtitle.instance = null;
    __decorate([
        property(cc.Label)
    ], Subtitle.prototype, "label", void 0);
    Subtitle = Subtitle_1 = __decorate([
        ccclass
    ], Subtitle);
    return Subtitle;
}(cc.Component));
exports.default = Subtitle;

cc._RF.pop();